package com.cmcc.passenger.data.entity

import android.os.Parcel
import android.os.Parcelable
import com.cmcc.passenger.data.entity.request.Coordinates
import com.cmcc.passenger.data.entity.response.CarCategory
import com.cmcc.passenger.data.entity.response.Tunnel
import com.google.gson.annotations.SerializedName


data class OrderRequest(
    @SerializedName("bountyFee")
    var bountyFee: String? = "0",
    @SerializedName("carCategory")
    var carCategory: CarCategory? = null,
    @SerializedName("endAddress")
    var endAddress: String? = null,
    @SerializedName("endCoordinates")
    var endCoordinates: Coordinates? = null,
    @SerializedName("remark")
    var remark: String? = "",
    @SerializedName("startAddress")
    var startAddress: String? = null,
    @SerializedName("startCoordinates")
    var startCoordinates: Coordinates? = null,
    @SerializedName("stationIndex")
    var stationIndex: String? = "",
    @SerializedName("status")
    var status: String? = "1",
    @SerializedName("tunnel")
    var tunnel: Tunnel? = null
) : Parcelable {
    constructor(parcel: Parcel) : this(
        parcel.readString(),
        parcel.readParcelable(CarCategory::class.java.classLoader),
        parcel.readString(),
        parcel.readParcelable(Coordinates::class.java.classLoader),
        parcel.readString(),
        parcel.readString(),
        parcel.readParcelable(Coordinates::class.java.classLoader),
        parcel.readString(),
        parcel.readString(),
        parcel.readParcelable(Tunnel::class.java.classLoader)
    ) {
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeString(bountyFee)
        parcel.writeParcelable(carCategory, flags)
        parcel.writeString(endAddress)
        parcel.writeParcelable(endCoordinates, flags)
        parcel.writeString(remark)
        parcel.writeString(startAddress)
        parcel.writeParcelable(startCoordinates, flags)
        parcel.writeString(stationIndex)
        parcel.writeString(status)
        parcel.writeParcelable(tunnel, flags)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<OrderRequest> {
        override fun createFromParcel(parcel: Parcel): OrderRequest {
            return OrderRequest(parcel)
        }

        override fun newArray(size: Int): Array<OrderRequest?> {
            return arrayOfNulls(size)
        }
    }
}